/*
 * Analysis.java
 *
 * Created on November 11, 2008, 9:01 PM
 */

package disk;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

import java.util.*;
import java.awt.event.*;
/**
 *
 * @author  limited
 */
public class Analysis extends javax.swing.JFrame {
//SparseTree   graph;
    
    Form f;


    /** Creates new form Analysis */

/*public void renderGraph()
{
    jPanel1.removeAll();
    
     pr = new PluggableRenderer();

     sbl=StringLabeller.getLabeller(graph);
     pr.setVertexStringer(sbl);
     Set r=graph.getVertices();
                  Iterator i=r.iterator();
                  Vertex v2;
                  while(i.hasNext())
                  {
                      
                    try{
                        v2=(Vertex)i.next();
                        sbl.setLabel(v2,v2.toString() );
                    }
                    catch(Exception ee)
                    {
                        ee.printStackTrace();
                    }
                    
                          
                      
                      
                  }
                  
                   vv = new VisualizationViewer(new KKLayout(graph), pr);
                   vv.addGraphMouseListener(new GraphMouseListener()
                   {
                        public void graphClicked(Vertex v,MouseEvent me)
                        {
                            System.out.println(v);
                            f.addVectorToPane((Vector)Form.groupMap.get(Integer.parseInt(v.toString())));
                            jPanel2.repaint();
                        }
                        public void graphPressed(Vertex v,MouseEvent me)
                        {}
                        public void graphReleased(Vertex v,MouseEvent me)
                        {}
                        
                        
                   
                   }
                   );
                   
                   jPanel1.add(vv);
}*/
    public Analysis(Form f) {
        initComponents();
       this.f=f;
       Form.dt.start();
       Form.dt.suspend();
      
      jTextField1.addKeyListener(new KeyAdapter()
      {
        public void keyTyped(KeyEvent ke) 
        {
        if(ke.isControlDown())
        {
        try{
        Form.analysis(jTextField1.getText(),jTextField2.getText(),true);
        
        }catch(Exception e)
        {}
        }
        
        }
      
      
      });
       
       
   setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    
 
 jButton1.addActionListener(new ActionListener()
         
 {
    public void actionPerformed(ActionEvent ae)
    {
        Form.groupMap.clear();
        try{
            
        
        Form.analysis(jTextField1.getText(),jTextField2.getText(),false);
        
        }catch(Exception e)
        {}
    }
 
 }
         
         );
    }

   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
  
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField1 = new javax.swing.JTextField();
	jTextField2 = new javax.swing.JTextField();

        jButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
	jButton2=new javax.swing.JButton();
	jtext=new javax.swing.JTextArea();
	jtext.setPreferredSize(new Dimension(500,500));
	jtext.setEditable(false);
	jtext.setLineWrap(true);
	JScrollPane areaScrollPane = new JScrollPane(jtext);
	areaScrollPane.setVerticalScrollBarPolicy(
	JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	areaScrollPane.setPreferredSize(new Dimension(490, 490));
	
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Submit");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(new FlowLayout());
       	jPanel1.add(areaScrollPane);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(null);
        

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
			.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1)
			)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, 500, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
//                        .addComponent(jPanel2, 500, 500, Short.MAX_VALUE)
                        ))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  //                  .addComponent(jPanel2, 500, 500, Short.MAX_VALUE)
                    .addComponent(jPanel1, 500, 500, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
		    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Analysis(new Form()).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
     private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
     private javax.swing.JTextField jTextField2;
     public static javax.swing.JTextArea jtext;
    // End of variables declaration//GEN-END:variables

}
